<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>达内－NetCTOSS</title>
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global_color.css" />
        <script language="javascript" type="text/javascript" src="../js/jquery-1.4.3.js"></script>
        <script language="javascript" type="text/javascript">
        	var roleName = false;
            //保存成功的提示消息
            function showResult() {
            	if(roleName == true){
            		var flag1 = 0;
		            var checkobj=document.getElementById("CheckBoxList");
		            var checks = checkobj.getElementsByTagName("input");
		            for(var n = 0; n<checks.length;n++){
		            	if( checks[n].checked==true){
		            		flag1=1;
		            	}
		            }
		            if(flag1==0){
		            	$("#save_result_info").text("请至少选择一项权限");
		                showResultDiv(true);
		                window.setTimeout("showResultDiv(false);", 3000);
		            	return;
		            }
		            alert("已经提交，点击确定返回列表");
	                document.forms[0].submit();
            	}else{
            		$("#save_result_info").text("角色名填写不正确");
		            showResultDiv(true);
		            window.setTimeout("showResultDiv(false);", 3000);
            	}
            }
            function showResultDiv(flag) {
                var divResult = document.getElementById("save_result_info");
                if (flag)
                    divResult.style.display = "block";
                else
                    divResult.style.display = "none";
            }
            $(function(){
	            $("#roleName").blur(function(){
	            	var reg = /^[\u4E00-\u9FA5A-Za-z0-9]{1,20}$/;
	            	if(reg.test($(this).val())){
	            		roleName = true;
	            		$("#roleNameMsg").removeClass("error_msg").text("输入正确");
	            	}else{
	            		roleName = false;
	            		$("#roleNameMsg").addClass("error_msg").text("请输入正确的角色名");
	            	}
	            });
            });
        </script>
    </head>
    <body>
        <!--Logo区域开始-->
        <div id="header">
            <img src="../images/logo.png" alt="logo" class="left"/>
            <a href="#">[退出]</a>            
        </div>
        <!--Logo区域结束-->
        <!--导航区域开始-->
        <div id="navi">
            <ul id="menu">
                <li><a href="../index/index" class="index_off"></a></li>
                <li><a href="../role/findRole" class="role_on"></a></li>
                <li><a href="../admin/findAdmin" class="admin_off"></a></li>
                <li><a href="../cost/findCost" class="fee_off"></a></li>
                <li><a href="../account/findAccount" class="account_off"></a></li>
                <li><a href="../service/findService" class="service_off"></a></li>
                <li><a href="../bill/findBill" class="bill_off"></a></li>
                <li><a href="../report/findReport" class="report_off"></a></li>
                <li><a href="../user/userInfo" class="information_off"></a></li>
                <li><a href="../user/userModiPwd" class="password_off"></a></li>
            </ul>
        </div>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">            
            <!--保存操作后的提示信息：成功或者失败-->
            <div id="save_result_info" class="save_success">保存成功！</div><!--保存失败，角色名称重复！-->
            <form action="addRole" method="post" class="main_form">
                <div class="text_info clearfix"><span>角色名称：</span></div>
                <div class="input_info">
                    <input type="text" class="width200" name="role.name" id="roleName"/>
                    <span class="required">*</span>
                    <div class="validate_msg_medium" id="roleNameMsg">不能为空，且为20长度的字母、数字和汉字的组合</div>
                </div>                    
                <div class="text_info clearfix"><span>设置权限：</span></div>
                <div class="input_info_high">
                    <div class="input_info_scroll" id="CheckBoxList">
                    	<s:checkboxlist name="role.privilegeIds" list="privileges" listKey="id" listValue="name" ></s:checkboxlist>
                    </div>
                    <span class="required">*</span>
                    <div class="validate_msg_tiny">至少选择一个权限</div>
                </div>
                <div class="button_info clearfix">
                    <input type="button" value="保存" class="btn_save" onclick="showResult();" />
                    <input type="button" value="取消" class="btn_save" onclick="javescript:history.go(-1);"/>
                </div>
            </form>
        </div>
        <!--主要区域结束-->
        <div id="footer">
            <span>[源自北美的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</span>
            <br />
            <span>版权所有(C)加拿大达内IT培训集团公司 </span>
        </div>
    </body>
</html>

